package com.xyy.saas.payment.service.impl;

import com.xyy.saas.payment.dao.mapper.AlipaySettingsMapper;
import com.xyy.saas.payment.dao.mapper.UnionPaySettingsMapper;
import com.xyy.saas.payment.dao.mapper.WxSettingsMapper;
import com.xyy.saas.payment.dao.model.AlipaySettings;
import com.xyy.saas.payment.dao.model.UnionPaySettings;
import com.xyy.saas.payment.dao.model.WxSettings;
import com.xyy.saas.payment.service.ChannelSettingsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (AlipaySettings)表服务实现类
 *
 * @author makejava
 * @since 2020-11-26 10:43:39
 */
@Service("channelSettingsService")
public class ChannelSettingsServiceImpl implements ChannelSettingsService {

    @Resource
    private AlipaySettingsMapper alipaySettingsDao;

    @Resource
    private WxSettingsMapper wxSettingsDao;

    @Resource
    private UnionPaySettingsMapper unionPaySettingsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public AlipaySettings queryAlipayById(Integer id) {
        return this.alipaySettingsDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<AlipaySettings> queryAlipayAllByLimit(int offset, int limit) {
        return this.alipaySettingsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 通过实体作为筛选条件查询
     *
     * @param alipaySettings 实例对象
     * @return 对象列表
     */
    @Override
    public List<AlipaySettings> queryAlipayAll(AlipaySettings alipaySettings) {
        return this.alipaySettingsDao.queryAll(alipaySettings);
    }

    /**
     * 新增数据
     *
     * @param alipaySettings 实例对象
     * @return 实例对象
     */
    @Override
    public AlipaySettings insertAlipay(AlipaySettings alipaySettings) {
        this.alipaySettingsDao.insert(alipaySettings);
        return alipaySettings;
    }

    /**
     * 修改数据
     *
     * @param alipaySettings 实例对象
     * @return 实例对象
     */
    @Override
    public AlipaySettings updateAlipay(AlipaySettings alipaySettings) {
        this.alipaySettingsDao.update(alipaySettings);
        return this.queryAlipayById(alipaySettings.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteAlipayById(Integer id) {
        return this.alipaySettingsDao.deleteById(id) > 0;
    }

   /**
     * 通过业务订单类型和支付方式查询
     * @param businessOrderType
     * @param payMode
     * @return
     */
   @Override
   public AlipaySettings queryAlipayByBusinessOrderTypeAndPayMode(String businessOrderType, String payMode) {
        return this.alipaySettingsDao.queryByBusinessOrderTypeAndPayMode(businessOrderType, payMode);
    }


    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public WxSettings queryWXById(Integer id) {
        return this.wxSettingsDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<WxSettings> queryWXAllByLimit(int offset, int limit) {
        return this.wxSettingsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param wxSettings 实例对象
     * @return 实例对象
     */
    @Override
    public WxSettings insertWX(WxSettings wxSettings) {
        this.wxSettingsDao.insert(wxSettings);
        return wxSettings;
    }

    /**
     * 修改数据
     *
     * @param wxSettings 实例对象
     * @return 实例对象
     */
    @Override
    public WxSettings updateWX(WxSettings wxSettings) {
        this.wxSettingsDao.update(wxSettings);
        return this.queryWXById(wxSettings.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteWXById(Integer id) {
        return this.wxSettingsDao.deleteById(id) > 0;
    }


    /**
     * 通过业务订单类型和支付方式查询
     * @param businessOrderType
     * @param payMode
     * @return
     */
    @Override
    public WxSettings queryWXByBusinessOrderTypeAndPayMode(String businessOrderType, String payMode) {
        return this.wxSettingsDao.queryByBusinessOrderTypeAndPayMode(businessOrderType, payMode);
    }

    /**
     * 通过实体作为筛选条件查询
     *
     * @param wxSettings 实例对象
     * @return 对象列表
     */
    @Override
    public List<WxSettings> queryWXAll(WxSettings wxSettings) {
        return this.wxSettingsDao.queryAll(wxSettings);
    }

    @Override
    public UnionPaySettings queryUnionPayById(Integer id) {
        return unionPaySettingsDao.queryById(id);
    }

    @Override
    public List<UnionPaySettings> queryUnionPayAllByLimit(int offset, int limit) {
        return unionPaySettingsDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<UnionPaySettings> queryUnionPayAll(UnionPaySettings unionPaySettings) {
        return unionPaySettingsDao.queryAll(unionPaySettings);
    }

    @Override
    public UnionPaySettings insertUnionPay(UnionPaySettings unionPaySettings) {
        unionPaySettingsDao.insert(unionPaySettings);
        return unionPaySettings;
    }

    @Override
    public UnionPaySettings updateUnionPay(UnionPaySettings unionPaySettings) {
        unionPaySettingsDao.update(unionPaySettings);
        return queryUnionPayById(unionPaySettings.getId());
    }

    @Override
    public boolean deleteUnionPayById(Integer id) {
        return unionPaySettingsDao.deleteById(id) > 0;
    }

    @Override
    public UnionPaySettings queryUnionPayByBusinessOrderTypeAndPayMode(String businessOrderType, String payMode) {
        return unionPaySettingsDao.queryByBusinessOrderTypeAndPayMode(businessOrderType, payMode);
    }

}